<template>

<div>
 <el-table
    :data="$store.getters['banner/getbannerlist']"
    border
    style="width: 100%">
    <el-table-column
      prop="id"
      label="编号"
      width="180">
    </el-table-column>
    <el-table-column
      prop="title"
      label="轮播图标题"
      width="180">
    </el-table-column>
   <el-table-column
      label="图片"
      width="180">
<template slot-scope="item">
        <img v-if="item.row.img" class="imgUrl" :src="item.row.img" alt="">
      </template>
    </el-table-column>
   <el-table-column

      label="状态">
 <el-button plain size="mini" type="danger">禁用</el-button>

    </el-table-column>
        <el-table-column label="操作">
         <template  slot-scope="item">
 <el-button plain  size="mini"  type="primary" @click='edit(item.row.id)'>编辑</el-button>
 <el-button plain size="mini" type="danger" @click="dit(item.row.id)">删除</el-button>
         </template>

    </el-table-column>

  </el-table>
</div>
</template>

<script>
import { bannerdelete } from '../../../api/api.js'
export default {
  data () {
    return {
      tableData: [{
        date: '1',
        name: '123123',
        img: '图片路径'

      }]
    }
  },
  mounted () {
    this.$store.dispatch('banner/getBanner')
  },
  methods: {
    dit (id) {
      this.$confirm('你确定要删除吗', '提示', {
        cancelButtonText: '取消',
        confirmButtonText: '确定',
        type: 'warning '

      }).then(() => {
        bannerdelete({ id }).then(res => {
          if (res.code === 200) {
            this.$message.success(res.msg)
            this.$store.dispatch('banner/getBanner')
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    edit (id) {
      this.$emit('edit', id)
    }

  }
}
</script>

<style scoped>
.imgUrl{
      width: 100px;

    height: 100%;
}
</style>
